package models

import (
	"common/uuid"
	"database/sql"
	"time"
)

type Node struct {
	IDx          uint32       `gorm:"column:idx;primary_key;notNull;auto_increment;comment:节点自增id" json:"idx"`
	ID           uuid.UUID    `gorm:"column:id;uniqueIndex;type:binary(16);notNull;comment:节点id" json:"id"`
	DevId        string       `gorm:"column:dev_id;size:100;notNull;default:'';comment:p2pid" json:"dev_id"`
	Ip           string       `gorm:"column:ip;size:150;notNull;default:'';comment:ip" json:"ip"`
	Ipv6         string       `gorm:"column:ipv6;size:150;notNull;default:'';comment:ipv6" json:"ipv6"`
	Nat          int8         `gorm:"column:nat;notNull;default:0;comment:nat类型" json:"nat"`
	Port         int          `gorm:"column:port;notNull;default:0;comment:端口" json:"port"`
	Fwd          int          `gorm:"column:fwd;notNull;default:0" json:"fwd"`
	Disqualified sql.NullTime `gorm:"column:disqualified;type:time;comment:取消时间" json:"disqualified"`
	Offline      sql.NullTime `gorm:"column:offline;type:time;comment:下线时间" json:"offline"`
	Region       string       `gorm:"column:region;size:100;NOT NULL;default:'';comment:区域" json:"region"`
	PublicIp     string       `gorm:"column:public_ip;size:20;NOT NULL;default:''" json:"public_ip"`
	FreeSpace    int64        `gorm:"column:free_space;NOT NULL;default:0;comment:可用硬盘空间" json:"free_space"`
	TotalSpace   int64        `gorm:"column:total_space;NOT NULL;default:0;comment:硬盘总空间" json:"total_space"`
	DataSpace    int64        `gorm:"column:data_space;NOT NULL;default:0;comment:硬盘占用空间" json:"data_space"`
	Version      string       `gorm:"column:version;NOT NULL;default:'';size:50;comment:版本号" json:"version"`
	VersionInt   uint32       `gorm:"column:version_int;NOT NULL;default:0;comment:版本号" json:"version_int"`
	CreatedAt    time.Time    `gorm:"column:created_at;type:time;NOT NULL;default:CURRENT_TIMESTAMP" json:"created_at"`
	LastContact  time.Time    `gorm:"column:last_contact;type:time;NOT NULL;default:CURRENT_TIMESTAMP" json:"last_contact"`
}
